-module(p9).
%-export([result/0]).
-compile(export_all).

pyth_triplets_bound_sum(Bound) ->
    Seq = lists:seq(1, Bound div 2),
    [{A, B, C} || A <- Seq, B <- Seq, C <- Seq,
                  A * A + B * B =:= C * C,
                  A + B + C =< Bound,
                  A < B, A < C, B < C].

pyth_triplets_exact_sum(Exact) ->
    Seq = lists:seq(1, Exact div 2),
    [{A, B, C} || A <- Seq, B <- Seq, C <- Seq,
                  A * A + B * B =:= C * C,
                  A + B + C =:= Exact,
                  A < B, A < C, B < C].

pyth_perimeters_bounded(Bound) ->
    Seq = lists:seq(1, Bound div 2),
    [A + B + C || A <- Seq, B <- Seq, C <- Seq,
                  A * A + B * B =:= C * C,
                  A + B + C =< Bound,
                  A < B, A < C, B < C].
